package site.zhouinfo.xml;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
 * java对象与xml互相转换 商品
 *
 * @author zhou
 * @create 2017-08-15 17:29
 * @email zhouinfo@qq.com
 * @blog blog.zhouinfo.site
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "goods")
@XmlType(propOrder = {"goodsId", "goodsName", "price", "count"})
public class Goods implements Serializable {

    private static final long serialVersionUID = 1L;

    private int goodsId;
    private String goodsName;
    private BigDecimal price;
    private int count;

    public Goods() {

    }

    public Goods(int goodsId, String goodsName, BigDecimal price, int count) {
        this.goodsId = goodsId;
        this.goodsName = goodsName;
        this.price = price;
        this.count = count;
    }

    public int getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(int goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"goodsId\":")
                .append(goodsId);
        sb.append(",\"goodsName\":\"")
                .append(goodsName).append('\"');
        sb.append(",\"price\":")
                .append(price);
        sb.append(",\"count\":")
                .append(count);
        sb.append('}');
        return sb.toString();
    }
}
